var radioComponent=Vue.extend({
  template: '#in-radio',
  props: {
    test: Number
  },
  data: function () {
    return {
      QuestionTitle:'单选按钮',
      OrderNum: this.test,
      ptype:'1',
      IsRequired: true,
      QuestionItem:[{Content: '选项一'},{Content: '选项二'},{Content: '选项三'}]
    }
  }
});
var checkboxComponent=Vue.extend({
  template: '#in-checkbox',
  props:{
    test: Number
  },
  data: function () {
    return {
      QuestionTitle:'多选',
      OrderNum: this.test,
      IsRequired:true,
      ptype:'2',
      QuestionItem:[{Content: '选项一'},{Content: '选项二'},{Content: '选项三'}]
    }
  }
});
var textComponent=Vue.extend({
  template: '#in-text',
  props: {
    test: Number
  },
  data: function () {
    return {
      QuestionTitle:'单行输入',
      OrderNum: this.test,
      IsRequired:true,
      ptype:'99',
      QuestionItem:null
    }
  }
});

var vm = new Vue({
    el: '#tem-info',
    components: {
        'input-radio': radioComponent,
        'input-checkbox': checkboxComponent,
        'input-text': textComponent
    },
    data: {
        quesTitle: '',
        desc: '',
        itemTemplate: []
    },
    methods: {
        add(component, index) {
            this.itemTemplate.push({
                'component': component,
                'cIndex': index
            })
        },
        remove(index) {
            this.itemTemplate.splice(index, 1);
        }
    }
});
$(function () {
   
  $(".tooList").on('click','li',function(){
    $('.panel-body').find('.body-conent').hide();
    vm.add($(this).attr("addtype"),vm.itemTemplate.length+1);
    setTimeout(function(){
      
      $('.panel-body:last-child').find('.body-conent').show();
      var a = $('.main').height();
      $("body,html").animate({
        scrollTop: a
      },500);
      // console.log($('.main').height());
    },500);
    
  });
  //编辑当前项
  $('.all-result').on('click','.body-btn .edit',function(){
    console.log(11);
    $(this).parents('.panel-body').siblings().find(".body-conent").hide();
    $(this).parents('.panel-body').find(".body-conent").show();
  });
  //删除当前项
   $('.all-result').on('click','.body-btn .delete',function(){
      var index=$(this).parents('.panel-body').index();
      vm.remove(index);
  });
  //保存
  $('.btn-save').on('click',function(){
      sendData();
      console.log(vm.$data)
  });
});
var ajaxData = {};
